package com.honey.standard.writer.imp;

import java.io.File;
import java.util.Date;
import java.util.Properties;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.core.compiler.CompilationDescriptor;
import com.honey.core.utils.Constant;
import com.honey.core.utils.TimeUtility;
import com.honey.standard.writer.JavaFileWrite;
import com.honey.standard.writer.StandardWriterPlugin;

/**
 * 保存java文件
 * @author Administrator
 *
 */
public class JavaFileWriteImp extends BaseFileWriter  implements JavaFileWrite{
	
	public JavaFileWriteImp(StandardWriterPlugin standardWriterPlugin) {
		super(standardWriterPlugin);
	}

	@Override
	public void writeJavaFile(CompilationDescriptor compilationDescriptor) {
		Properties props=System.getProperties();
		AbstractJavaCompilation compilation =(AbstractJavaCompilation)compilationDescriptor.getCompilation();
		compilation.addClassComment("Generate Date : " + TimeUtility.format(new Date(), TimeUtility.FORMAT_DATE_ONLY));
		compilation.addClassComment("Generate Version : " + Constant.VERSION );
		compilation.addClassComment("Generate Name : " + Constant.PROJECT_NAME );
		compilation.addClassComment("Generate User : " + props.getProperty("user.name"));
		compilation.addClassComment("JDK Version : " + Constant.SINCE );
		
		super.writeFile(compilationDescriptor);
	}

	
	@Override
	public File getTargetFile() {
		
		return super.getTargetFile();
	}	
}
